<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>修改页面</title>
	<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
	<div class="mainBox">
		<div class="main-container">
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="text" name="user_name" lay-verify="title" autocomplete="off" placeholder="请输入标题"
						   class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">性别</label>
				<div class="layui-input-block">
					<input type="radio" name="sex" value="男" title="男">
					<input type="radio" name="sex" value="女" title="女" checked>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">账号</label>
				<div class="layui-input-block">
					<input type="text" name="account_number" lay-verify="title" autocomplete="off" placeholder="请输入标题"
						   class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-block">
					<input type="text" name="password" lay-verify="title" autocomplete="off" placeholder="请输入标题"
						   class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">邮箱</label>
				<div class="layui-input-block">
					<input type="text" name="email" lay-verify="title" autocomplete="off" placeholder="请输入标题"
						   class="layui-input">
				</div>
			</div>
		</div>
	</div>
	<div class="bottom">
		<div class="button-container">
			<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
					lay-filter="user-save">
				<i class="layui-icon layui-icon-ok"></i>
				提交
			</button>
			<button type="reset" class="pear-btn pear-btn-sm">
				<i class="layui-icon layui-icon-refresh"></i>
				重置
			</button>
		</div>
	</div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
	var user_id=window.location.href.split("=")[1];
	console.log(user_id);
	layui.use(['form', 'jquery'], function() {

		let form = layui.form;
		let $ = layui.jquery;

		form.on('submit(user-save)', function(data) {
			$.ajax({
				url: 'http://localhost:8080/dreamgame/user/update/'+user_id,
				data: JSON.stringify(data.field),
				dataType: 'json',
				contentType: 'application/json',
				type: 'put',
				success: function(result) {
					if (result.success) {
						layer.msg(result.msg, {
							icon: 1,
							time: 1000
						}, function() {
							parent.layer.close(parent.layer.getFrameIndex(window
									.name)); //关闭当前页
							parent.layui.table.reload("user-table");
						});
					} else {
						layer.msg(result.msg, {
							icon: 2,
							time: 1000
						});
					}

				}
			})
			return false;
		});


		// $.ajax({
		// 	url: 'http://localhost:8080/dreamgame/user/query',
		//
		// })
	})
</script>
<script>
</script>
</body>
</html>
